Socket
Socket
Sign inDemoInstall

@turf/center

Package Overview
Dependencies
Maintainers
9
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/center

turf center module


Version published
Weekly downloads
586K
increased by6.89%
Maintainers
9
Weekly downloads
 
Created

What is @turf/center?

@turf/center is a module from the Turf.js library that calculates the center of a given GeoJSON feature or set of features. It is useful for geographic data analysis and visualization, allowing developers to easily find the central point of various geometries such as polygons, lines, and multi-point collections.

What are @turf/center's main functionalities?

Calculate Center of a Polygon

This feature calculates the center point of a polygon. The code sample demonstrates how to create a polygon and then find its center using the @turf/center package.

const turf = require('@turf/center');
const polygon = turf.polygon([[
  [-81, 41],
  [-81, 47],
  [-72, 47],
  [-72, 41],
  [-81, 41]
]]);
const center = turf(polygon);
console.log(center);

Calculate Center of a MultiPoint Collection

This feature calculates the center point of a collection of points (MultiPoint). The code sample shows how to create a MultiPoint collection and find its center using the @turf/center package.

const turf = require('@turf/center');
const multiPoint = turf.multiPoint([
  [-81, 41],
  [-81, 47],
  [-72, 47],
  [-72, 41]
]);
const center = turf(multiPoint);
console.log(center);

Calculate Center of a LineString

This feature calculates the center point of a LineString. The code sample demonstrates how to create a LineString and find its center using the @turf/center package.

const turf = require('@turf/center');
const lineString = turf.lineString([
  [-81, 41],
  [-81, 47],
  [-72, 47],
  [-72, 41]
]);
const center = turf(lineString);
console.log(center);

Other packages similar to @turf/center

Keywords

FAQs

Package last updated on 09 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc